<%@page import="qldc.pm.qtht.dmdc.constants.MaLoaiHoSo"%>
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.liferay.portal.kernel.util.Validator"%>
<%@page import="qldc.pm.tiensu.constants.ChucNangPhanMemPermision"%>
<%@page import="qldc.pm.qtht.model.ChucNangPhanMem"%>
<%@page import="java.util.List"%>
<%@page import="qldc.pm.qtht.utils.NguoiDungUtils"%>
<%@include file="init.jsp"%>

<%
List<ChucNangPhanMem> tongChucNangPhanMems = NguoiDungUtils.getChucNangTheoNguoiDung(MaLoaiHoSo.QLTS.toString(), user.getUserId());

String chucNangItem = "";

Map<String, ChucNangPhanMem> dsChucNangPhanMems = new HashMap<String, ChucNangPhanMem>();

for (ChucNangPhanMem chucNangPhanMem : tongChucNangPhanMems) {
	if (Validator.isNotNull(chucNangPhanMem)) {
		dsChucNangPhanMems.put(chucNangPhanMem.getMaChucNangPhanMem(), chucNangPhanMem);
	}
}

if(!dsChucNangPhanMems.isEmpty()) {
	if (null != dsChucNangPhanMems.get(ChucNangPhanMemPermision.TIENSU_NCTS.getMaChucNang())) {
		chucNangItem = ChucNangPhanMemPermision.TIENSU_NCTS.getChucNang();
	}
	
	if(Validator.isNull(chucNangItem)) {
		chucNangItem = ChucNangPhanMemPermision.fromMaChucNang(tongChucNangPhanMems.get(0).getMaChucNangPhanMem()).getChucNang();
	}
}

String chonChucNangItem = ParamUtil.getString(request, "chonChucNangItem", chucNangItem);
%>


<liferay-ui:error key="thao-tac-khong-thanh-cong" message="thao-tac-khong-thanh-cong" />

<liferay-ui:error key="vui-long-dang-nhap" message="vui-long-dang-nhap" />
<liferay-ui:error key="cap-nhat-yeu-cau-trich-luc-khong-thanh-cong" message="cap-nhat-yeu-cau-trich-luc-khong-thanh-cong" />
<liferay-ui:error key="xoa-yeu-cau-trich-luc-khong-thanh-cong" message="xoa-yeu-cau-trich-luc-khong-thanh-cong" />

<liferay-ui:success key="them-moi-yeu-cau-trich-luc-thanh-cong" message="them-moi-yeu-cau-trich-luc-thanh-cong" />
<liferay-ui:success key="xoa-yeu-cau-trich-luc-thanh-cong" message="xoa-yeu-cau-trich-luc-thanh-cong" />
<liferay-ui:success key="cap-nhat-yeu-cau-trich-luc-thanh-cong" message="cap-nhat-yeu-cau-trich-luc-thanh-cong" />

<liferay-ui:error message="chuc-nang-chua-duoc-ho-tro" key="chuc-nang-chua-duoc-ho-tro" />
<liferay-ui:success key="them-moi-ket-qua-trich-luc-thanh-cong" message="them-moi-ket-qua-trich-luc-thanh-cong" />
<liferay-ui:success key="cap-nhat-ket-qua-trich-luc-thanh-cong" message="cap-nhat-ket-qua-trich-luc-thanh-cong" />
<liferay-ui:success key="cap-nhat-ket-qua-trich-luc-khong-thanh-cong" message="cap-nhat-ket-qua-trich-luc-khong-thanh-cong" />

<!--  xoa an tich -->
<liferay-ui:success key="ky-duyet-xoa-an-tich-thanh-cong" message="ky-duyet-xoa-an-tich-thanh-cong" />
<liferay-ui:success key="ky-duyet-danh-sach-xoa-an-tich-thanh-cong" message="ky-duyet-danh-sach-xoa-an-tich-thanh-cong" />

<liferay-ui:success key="tao-ho-so-xoa-an-tich-thanh-cong" message="tao-ho-so-xoa-an-tich-thanh-cong" />

<!--  ban giao ho so -->
<liferay-ui:success key="luu-bien-ban-ban-giao-ho-so-thanh-cong" message="luu-bien-ban-ban-giao-ho-so-thanh-cong" />

<div class="portlet-DMDC portlet-Container">


	<%
		if ((tongChucNangPhanMems != null) && !tongChucNangPhanMems.isEmpty()) {
	%>
	<div class="wapper-Left">
		<liferay-util:include page="/html/tiensu/chon_chuc_nang.jsp" servletContext="<%=this.getServletContext()%>" />
	</div>


	<%
		boolean isNotSupported = false;
	%>

	<div class="wapper-Right">


		<%
		boolean notImplement = true;
		for (ChucNangPhanMemPermision chucNangPhanMem : ChucNangPhanMemPermision.values()) {
	
			if (chucNangPhanMem.getChucNang().equals(chonChucNangItem)) {
				notImplement = false;
		%>
	
		<liferay-util:include page="<%=chucNangPhanMem.getPath()%>" servletContext="<%=this.getServletContext()%>" />
	
		<%
			}
		}
		
		if (notImplement) {
		%>
		<h2 class="tle-Content">
			<liferay-ui:message key="<%=dsChucNangPhanMems.get(chonChucNangItem).getTenChucNangPhanMem()%>" />
		</h2>
	
		<div class="main-Content">
			<div class="alert alert-info">
				<liferay-ui:message key="chuc-nang-chua-duoc-ho-tro"></liferay-ui:message>
			</div>
		</div>
		<%
		}
		%>
		
		</div>
		
		<%
		} else {
		%>
		
		<div class="alert alert-info">
			<liferay-ui:message key="ban-khong-co-quyen-thao-tac-tren-phan-mem-nay"></liferay-ui:message>
		</div>
		<%
		}
		%>
</div>